//-----------------------------------------------------------------------------
// File: DrawerShapesCollection.cs
//
// Copyright (c) Dmitry Shuklin. All rights reserved.
//-----------------------------------------------------------------------------
using System;

namespace ObjectiveDraw.Platform.DrawerShapes
{
	/// <summary>
	/// Summary description for DrawerShapesCollection.
	/// </summary>

	public class DrawerShapeCollection:System.Collections.ICollection
	{
		protected ObjectiveDraw.Platform.DrawerChartBase m_Owner;
		protected System.Collections.ArrayList m_List;

		public DrawerShapeCollection(ObjectiveDraw.Platform.DrawerChartBase owner, System.Collections.ArrayList list)
		{
			m_Owner = owner;
			m_List = list;
		}

		public ObjectiveDraw.Platform.IDrawerShape this[ int index ]  
		{
			get
			{
				return( (ObjectiveDraw.Platform.IDrawerShape) m_List[index] );
			}
		}


		public bool Contains( ObjectiveDraw.Platform.IDrawerShape value )  
		{
			// If value is not of type DrawerTickerInfo, this will return false.
			return( m_List.Contains( value ) );
		}

		public int Add(ObjectiveDraw.Platform.IDrawerShape shape)
		{
			m_Owner.ResetShapesCache();
			return m_List.Add(shape);
		}

		public void Remove(ObjectiveDraw.Platform.IDrawerShape shape)
		{
			m_Owner.ResetShapesCache();
			m_List.Remove(shape);
		}

		#region ICollection Members

		public bool IsSynchronized
		{
			get
			{
				// TODO:  Add PortfolioCollection.IsSynchronized getter implementation
				return false;
			}
		}

		public int Count
		{
			get
			{
				return m_List.Count;
			}
		}

		public void CopyTo(Array array, int index)
		{
			m_List.CopyTo(array, index);
		}

		public object SyncRoot
		{
			get
			{
				return m_List.SyncRoot;
			}
		}

		#endregion

		#region IEnumerable Members

		public System.Collections.IEnumerator GetEnumerator()
		{
			return m_List.GetEnumerator();
		}

		#endregion

	}
}
